using CMS.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CMS.EFCore.Config;

public class ArticleCommentConfig : IEntityTypeConfiguration<ArticleComment>{
    public void Configure(EntityTypeBuilder<ArticleComment> builder) {
        builder.Property(a => a.Msg).IsRequired().HasMaxLength(200);
        // 配置一对多关系
        builder.HasOne(a => a.Article).WithMany(a => a.ArticleComments).IsRequired().HasForeignKey(a => a.ArticleId);
    }
}